Candidate Feature |
EasyMock Support |
SevenMock Support |
Ability to mock both classes and interfaces |
EasyMock mocks interfaces only by default. An extension is available to allow the mocking of classes. |
SevenMock requires concrete classes to work. If no convenient class exists, is necessary to create a simple adapter class for the test. |
Flexibile parameter matching |
By default, EasyMock matches all parameters using the equals() operation. It is possible to override this by creating custom argument matchers, but the resulting test code tends to be hard to follow if a matcher is created for each mocked operation. |
SevenMock expects all parameter assertions to be explicit in the test code - so the test writer has complete flexibility when deciding what assertions to make. |
Clear syntax |
The syntax of EasyMock tests is very clear and intuitive provided that default (equality based) argument matching is used. |
The syntax of SevenMock tests is not quite as self-explanatory as EasyMock, but tests are very clear once the developer is familiar with the way that inner classes are used to define the mocked operations. |
Support for IDE refactoring tools |
EasyMock uses actual operation calls to define mocked operations. This supports IDE refactoring very well. |
SevenMock tests also refer to actual operations and so support IDE refactoring well too. |
Ease of test debugging |
EasyMock provides a description of the problem if an expectation is wrong in some way. If arguments mismatch, details of the parameters are printed. With complex parameter graphs or tests with many similar expectations, it can be tricky to work out exactly what is failing. |
SevenMock checks that the correct operations have been called, but all parameter testing is contained in the body of the test. If anything is wrong, the java stack trace will point to the assertion that failed. Test developers are able to provide custom messages for specific failures. |
Flexible sequencing of operations |
EasyMock allows the test developer to choose between strict and flexible sequencing. It is also possible to specify flexibility in the number of times a particular operation is called. |
Flexible sequencing is not currently supported by SevenMock. |
Support for sequence enforcement across multiple mock objects |
EasyMock allows enforcement of sequencing by using optional mock controls. |
SevenMock enforces sequencing of operations across different mock objects. |